home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-07-04 | 3.3 KB | 112 lines | [TEXT/EDIT] |
- ; This file is: dInterp.txt -- interpreter and compiler
- ; Mon Apr 25, 1988 15:11:43 macros
- ; Wed Apr 27, 1988 12:30:07 v 1.4
- ; Thu Jul 04, 1991 05:20:00 add open control key
-
- inKey: ; ( key.data -- )
- BTST #0,evtMeta(A0) ; is the command key down?
- BEQ.S @0
-
- CMPI.B #'v',1(PS) ; is the key 'v'?
- BNE.S @4 ; if so then
-
- ADDQ #2,PS ; drop the ASCII and ...
- JMP paste-base(BP) ; ... interpret from clipboard
-
- @4: CMPI.B #'o',1(PS) ; is the key 'o'?
- BNE.S @0 ; if not skip ahead.
-
- ADDQ #2,PS
- JMP open-base(BP) ; get and interpret file
-
- @0: JSR TextNormal-base(BP) ; set font, mode and size
- _ObscureCursor ; hide the mouse cursor
- JSR NoCurs-base(BP) ; erase the cursor
- MOVE (PS)+,D0 ; retrieve the key data
- CMPI.B #CR,D0 ; is the character a CR
- BEQ.S Interpret ; if so: interpret the line
-
- CMPI.B #BS,D0 ; is the character a backspace?
- BNE.S @1
-
- TST.B Counter ; rubout the previous character
- BLE.S @3 ; if count > 0 then
-
- SUBQ.B #1,Counter ; decrement count
- MOVE.B #BL,0(IS,Counter) ; in buffer and ...
- JSR doDel-base(BP)
- JSR Space-base(BP) ; on terminal
- JSR doDel-base(BP)
- BRA.S @3
-
- @1: CMPI.B #80,Counter ; is the buffer full
- BEQ.S @2 ; then just emit it
-
- MOVE.B D0,0(IS,Counter.W) ; stash the char into the buffer
- ADDQ #1,Counter ; increment char count
- @2: JSR EmitCode-base(BP) ; emit the character
- @3: RTS
-
- Interpret: ; interpret a line of code
- JSR doCR-base(BP) ; emit the CR
- MOVE.B #0,1(IS,Counter.W) ; plant a null in the buffer
- Main: JSR token-Base(BP) ; get the next word
- MOVE Dict,-(PS) ; push pointer to last name
- JSR search-Base(BP) ; find current token in dictionary
- TST (PS)+ ; found NOT IF,
- BEQ.S TestNum ; ... assume its a number
- BCLR #7,fimmed-base(BP) ; ELSE, immediate? IF
- BNE.S GoDo ; ... do it
- TST.B fcolon-base(BP) ; ELSE, compiling? NOT IF,
- BEQ.S GoDo ; ... do it
- BCLR #7,fmacro-base(BP) ; ELSE, macro? IF
- BNE.S domc
- JSR compile-base(BP) ; ELSE, compile a JSR to it
- BRA.S Main
- godo: JSR execute-base(BP)
- JSR StkChk-base(BP)
- BRA.S Main
- domc: JSR mcomp-base(BP)
- BRA.S Main
-
- TestNum:
- JSR here-base(BP) ; get the relative address of token
- JSR number-base(BP) ; convert it to a value, if posible
- TST (PS)+ ; was it?
- BNE.S @0 ; IF NOT,
- BRA.S Whazat ; say huh??? and EXIT
- @0: TST.B fcolon-base(BP) ; THEN, are you compiling?
- BEQ.S Main ; IF NOT, leave it on the stack
- JSR literal-base(BP) ; ELSE, compile it as a literal
- BRA.S Main ; THEN, get on with it
-
- ; ----- the dictionary ------
-
- DictStart:
- DCB.B 6,0 ; End of dictionary search
-
- DC.B 129,13,0,0 ; "{cr}" ( -- )
- DC.W DictStart-base
- CRet: JSR pasting-base(BP) ; interpret from the scrap
- TST.B fint-base(BP)
- BEQ.S @0
- MOVE.B #0,0(IS,D5) ; replace CR with null
- @0: BRA.S Main
-
- DC.B 129,0,0,0 ; "{null}" ( -- )
- DC.W cret-theLink ; interpret from the keyboard
- NRet: JSR clearTermBuf-base(BP)
- CLR.L Counter ; clear input buffer offset
- TST.B fcolon-base(BP)
- BNE.S @0 ; don't issue prompt if compiling
- JSR prompt-base(BP)
- @0: JMP kdone-base(BP) ; jump back to the application
-
- DC.B 9,'?TE' ; "?terminal" ( -- flag )
- DC.W nret-theLink ; is a key pressed?
- qTerm: JMP qtcode-base(BP)
-
- DC.B 3,'KEY' ; "key" ( -- ascii )
- DC.W qterm-theLink ; wait for a key press
- Key: JMP keycode-base(BP)
-